<?php

namespace app\admin\model;

use think\Model;
use think\Db;

class Comment extends Model
{

    

    

    // 表名
    protected $name = 'comment';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    

        public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->bind('nickname');
    }
        protected static function init()
    {
        self::afterInsert(function ($row) {
            $email_id = $row['email_id'];
            Db::name('email')->where(['id'=>$email_id])->setInc('comment_num');
        });
    }






}
